<?php
namespace app\admin\validate\user;

use \think\Validate;

class User extends Validate
{
    protected $rule = [
        'user_account' => 'require|max:20|alphaNum|token',
        'user_name' => 'require|max:20',
        'user_password' => 'require|alphaNum|max:16|min:6',
        'user_phone' => ['regex' => '/^1[34578]{1}\d{9}$/'],
        'user_email' => 'email',
        'user_check_password' => 'require|confirm:user_password'
    ];

    protected $message = [
        'user_account.require' => '会员编号不能为空',
        'user_account.max' => '会员编号不能超过20个字符',
        'user_account.alphaNum' => '会员编号由字母或数字组成',
        'user_name.require' => '会员昵称不能为空',
        'user_name.max' => '会员昵称不能超过20个字符',
        'user_password.require' => '密码不能为空',
        'user_password.max' => '密码不能超过16个字符',
        'user_password.min' => '密码不能少于6个字符',
        'user_password.alphaNum' => '密码由字母或数字组成',
        'user_check_password.require' => '请输入确认密码',
        'user_check_password.confirm' => '两次输入的密码不一致',
        'user_phone.regex' => '手机号输入不正确',
        'user_email.email' => '邮箱输入不正确',
    ];

    protected $scene = [
        'edit' => ['user_account', 'user_name', 'user_phone', 'user_email']
    ];
}